# +----------------------------------------------------------------------
# | ChatWork智能聊天办公系统
# +----------------------------------------------------------------------
# | 软件声明: 本系统并非自由软件,未经授权任何形式的商业使用均属非法。
# | 版权保护: 任何企业和个人不允许对程序代码以任何形式任何目的复制/分发。
# | 授权要求: 如有商业使用需求,请务必先与版权所有者取得联系并获得正式授权。
# +----------------------------------------------------------------------
# | Author: ChatWork Team <2474369941@qq.com>
# +----------------------------------------------------------------------
from decimal import Decimal
from typing import Union
from fastapi import Query
from pydantic import BaseModel, Field


class RechargeSearchIn(BaseModel):
    """ 充值记录搜索参数 """
    page_no: int = Query(default=1, gt=0, description="当前页码")
    page_size: int = Query(default=15, gt=0, le=200, description="每页条数")
    user: Union[str, None] = Query(default=None, description="用户信息")
    order_sn: Union[str, None] = Query(default=None, description="充值单号")
    pay_way: Union[str, int, None] = Query(default=None, description="支付方式: [2=微信, 3=支付宝]")
    pay_status: Union[str, int, None] = Query(default=None, description="支付状态: [0=未支付, 1=已支付]")
    start_time: Union[int, str, None] = Query(default=None, description="开始时间")
    end_time: Union[int, str, None] = Query(default=None, description="结束时间")


class RechargeRefundIn(BaseModel):
    """ 充值退款参数 """
    id: int = Field(..., ge=0, description="订单ID")


"""--------------- Separator ---------------"""


class RechargeListVo(BaseModel):
    """ 充值记录列表Vo """
    id: int = Field(description="文章ID")
    order_sn: str = Field(description="充值单号")
    pack_name: str = Field(description="套餐名称")
    points_num: int = Field(description="积分数量")
    train_num: int = Field(description="训练组数")
    robot_num: int = Field(description="智能体数")
    know_num: int = Field(description="知识库数")
    paid_amount: Decimal = Field(description="实付金额")
    pay_way: str = Field(description="支付方式")
    pay_status: int = Field(description="支付状态: [0=未支付, 1=已支付]")
    refund_status: int = Field(description="退款状态: [0=未退款, 1=退款中, 2=退款成功, 3=退款失败]")
    create_time: str = Field(description="创建时间")
    pay_time: str = Field(description="支付时间")
    user: dict = Field(default="用户信息")

    class Config:
        json_schema_extra = {
            "example": {
                "id": 2,
                "order_sn": "B918447816245681",
                "pack_name": "体验套餐",
                "points_num": 10,
                "train_num": 0,
                "robot_num": 0,
                "know_num": 0,
                "paid_amount": 0.01,
                "pay_way": "微信支付",
                "pay_status": 1,
                "create_time": "2023-09-18 21:46:21",
                "pay_time": "2023-09-18 21:46:24",
                "user": {
                    "sn": "80965941",
                    "avatar": "http://0.0.0.0:8100/xiao.png",
                    "mobile": "13800138000",
                    "nickname": "xiao"
                }
            }
        }
